/*
 * Copyright 2010-2012 Susanta Tewari. <freecode4susant@users.sourceforge.net>
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */

package org.stat.model.comparison;

import org.stat.model.Model;

/**
 *
 * @author stewari1
 */
public class ModelMSEComparator implements ModelErrComparator {

    public int compare(Model m1, Model m2) {

        int result = 0;

        if ((m1 instanceof MSEComparable) && (m2 instanceof MSEComparable)) {

            MSEComparable mseComparable1 = (MSEComparable) m1;
            MSEComparable mseComparable2 = (MSEComparable) m2;
            double diff                  = mseComparable1.getMSE() - mseComparable2.getMSE();

            if (diff == 0) result = 0;
            if (diff > 1) result = 1;
            if (diff < 0) result = -1;
        }

        return result;
    }
}
